package com.giaothong.model;

import org.json.JSONObject;

import com.giaothong.config.Define;
import com.giaothong.model.entity.LocationStatus;
import com.giaothong.utils.JSONUtil;

public class ModelSendLocationStatusRequest {
	private int code;
	private LocationStatus locationStatus;

	/**
	 * setter & getter
	 */
	public void setCode(int code) {
		this.code = code;
	}

	public void setLocationStatus(LocationStatus locationStatus) {
		this.locationStatus = locationStatus;
	}

	public int getCode() {
		return code;
	}

	public LocationStatus getLocationStatus() {
		return locationStatus;
	}

	/**
	 * contructor
	 */

	public ModelSendLocationStatusRequest() {
		setDefautValue();
	}

	public ModelSendLocationStatusRequest(JSONObject jsonObject) {
		setDefautValue();
		if (jsonObject == null)
			return;
		this.code = JSONUtil.intTryGetValue(jsonObject, Define.CODE);
		if (code != Define.CODE_SUCCESSFULL)
			return;
		this.locationStatus = new LocationStatus(JSONUtil.jsonObjectTryGetValue(jsonObject, Define.DATA));
	}

	private void setDefautValue() {
		this.code = -1;
		this.locationStatus = new LocationStatus();
	}

}
